/******************************************************************
 * Copyright(c)  : Industry.soufun.com 2013
 * Description   : Auto generat code 
 * CreateDate    : 2013-09-29
 * Creater       : Industry
 * LastChangeDate: 
 * LastChanger   : 
 * Version Info  : 1.0
 * ******************************************************************/
using System;
using System.Data;
using System.Collections.Generic;
using Industry.Proj.EntityCore;
using Onlyle.Model;
using Onlyle.DAO;
using Industry.Framework.Common.Helper;

namespace Onlyle.Business
{
    public class GaoXiao_ArticleBLL
    {
	#region Add

	    public bool AddGaoXiao_Article(E_GaoXiao_Article GaoXiao_Article)
        {
            return GaoXiao_ArticleDA.AddGaoXiao_Article(GaoXiao_Article);
        }
        public bool AddGaoXiao_ArticleList()
        {
            List<E_GaoXiao_Article> GaoXiao_Articlelist = new List<E_GaoXiao_Article>();
            
            return GaoXiao_ArticleDA.AddGaoXiao_Article(GaoXiao_Articlelist);
        }
        #endregion
        
        #region Update

        public bool UpDateGaoXiao_Article(E_GaoXiao_Article GaoXiao_Article)
        {
            
            return GaoXiao_ArticleDA.UpDateGaoXiao_Article(GaoXiao_Article);
        }
        public bool UpDateGaoXiao_ArticleList()
        {
            List<E_GaoXiao_Article> GaoXiao_Articlelist = new List<E_GaoXiao_Article>();
            
            return GaoXiao_ArticleDA.UpDateGaoXiao_Article(GaoXiao_Articlelist);
        }
        #endregion
        
        #region Delete
      
        public bool DeleteGaoXiao_Article(E_GaoXiao_Article GaoXiao_Article)
        {
            
            return GaoXiao_ArticleDA.DeleteGaoXiao_Article(GaoXiao_Article);
        }
        public bool DeleteGaoXiao_ArticleList()
        {
            List<E_GaoXiao_Article> GaoXiao_Articlelist = new List<E_GaoXiao_Article>();
            
            return GaoXiao_ArticleDA.DeleteGaoXiao_Article(GaoXiao_Articlelist);
        }
        #endregion
        
        
        #region SELECT
        public List<E_GaoXiao_Article> SelectAll()
        {
            List<E_GaoXiao_Article> list = new List<E_GaoXiao_Article>();
            try
            {
                list = GaoXiao_ArticleDA.SelectAll();
            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return list;
        }

        public List<E_GaoXiao_Article> Select(E_GaoXiao_Article GaoXiao_Article)
        {
            List<E_GaoXiao_Article> list = new List<E_GaoXiao_Article>();
           
            try
            {
                list = GaoXiao_ArticleDA.Select(GaoXiao_Article);
            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return list;
        }
        public List<E_GaoXiao_Article> Select(string pageNum, string Type)
        {
            int pageStartNum = 1;
            int pageEndNum = 10;
            List<E_GaoXiao_Article> List = new List<E_GaoXiao_Article>();
            try
            {
                if (string.IsNullOrEmpty(pageNum)||!ValidatorHelper.IsNumber(pageNum))
                {
                    pageNum = "1";
                }
                if (ValidatorHelper.IsNumber(pageNum))
                {
                    pageStartNum = (Convert.ToInt32(pageNum) - 1) * 10 + 1;
                    pageEndNum = 10 * Convert.ToInt32(pageNum) ;
                }
                //pageStartNum=
                if (Type == GaoXiaoTypeEnum.gaoxiao.ToString())
                {
                    List = GaoXiao_ArticleDA.Select(pageStartNum, pageEndNum);
                }
                else
                {
                    List = GaoXiao_ArticleDA.Select(pageStartNum, pageEndNum, Type);
                }
                return List;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        public List<E_GaoXiao_Article> SelectDayRecommendData(string type)
        {
            List<E_GaoXiao_Article> List = new List<E_GaoXiao_Article>();
            try
            {
                List = GaoXiao_ArticleDA.SelectDayRecommendData(type);
                return List;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        public List<E_GaoXiao_Article> SelectGaoXiao_Detail(string key)
        {
            List<E_GaoXiao_Article> List = new List<E_GaoXiao_Article>();
            try
            {
                if (StringHelper.StrToId(key) > 0)
                {
                    List = GaoXiao_ArticleDA.SelectGaoXiao_Detail(key);
                }
                return List;
            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }


        public int GetGaoXiaoArticleCountByType(string type)
        {
            try
            {
                object o;
                if (type == GaoXiaoTypeEnum.gaoxiao.ToString())
                {
                    o = GaoXiao_ArticleDA.GetGaoXiaoArticleCountForIndex();
                }
                else
                {
                    o = GaoXiao_ArticleDA.GetGaoXiaoArticleCountByType(type);
                }
                if (ValidatorHelper.IsNumber(o.ToString()))
                {
                    return Convert.ToInt32(o.ToString());
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return 0;
        }

        public List<E_GaoXiao_Article> SelectGaoXiaoForIndexPage()
        {
            List<E_GaoXiao_Article> collection = new List<E_GaoXiao_Article>();
            try
            {
                collection = GaoXiao_ArticleDA.SelectGaoXiaoForIndex();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return collection;
        }
      
        #endregion
    }
}









